﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using FantasticCommonLibrary.ProcessWrapper;

namespace ZhuangBi
{
    public class Program
    {
        public static void Main(string[] args)
        {
            try
            {

                var commands = LoadConfig();
                if (commands != null && commands.Any())
                    commands.RunMultiCommand(true);
                Console.WriteLine("5秒后退出");
                Thread.Sleep(5000);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }

        }

        private static List<string> LoadConfig()
        {
            string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.txt");
            if (!File.Exists(fileName))
            {
                Console.WriteLine("文件不存在，无法装逼");
                throw new Exception("文件不存在");
            }
            var ss = new List<string>();
            StreamReader sr = new StreamReader(fileName, Encoding.UTF8);
            string s;
            while (!string.IsNullOrWhiteSpace(s = sr.ReadLine()))
            {
                ss.Add(s);
            }
            return ss;
            //using (StreamReader file = System.IO.File.OpenText(fileName))
            //{
            //    JsonSerializer serializer = new JsonSerializer();
            //    var list = (string[])serializer.Deserialize(file, typeof(string[]));
            //    return list;
            //}
        }
    }
}
